/**
 * 全局用户信息、token、session等保存
 */
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state:{
		user:{},
		company:{},
		member:{},
		userType:'',
		token:''
	},
	getters:{
		getUser(state){
			return state.user;
		},
		getToken(state){
			return state.token;
		}
	},
	mutations:{
		login(state,user,token){
			state.user = user;
			state.token = token;
		},
		logout(state){
			state.user = {};
			state.token = '';
		}
	},
	actions:{
		login(context,user,token){
			context.commit("login",user,token)
		},
		logout(context){
			context.commit("logout")
		}
	}
})

export default store;